FILE(GLOB FOO_PROTOS "*.proto")


FOREACH(FIL ${FOO_PROTOS})
  GET_FILENAME_COMPONENT(ABS_FIL ${FIL} ABSOLUTE)
  GET_FILENAME_COMPONENT(FIL_WE ${FIL} NAME_WE)

  LIST(APPEND FOO_SRCS "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
  LIST(APPEND FOO_HDRS "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")

  EXECUTE_PROCESS(
      COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${PROTO_META_BASE_DIR} ${FIL}
      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  )
ENDFOREACH()

MESSAGE(STATUS "FOO_PROTOS " ${FOO_PROTOS})
MESSAGE(STATUS "FOO_SRCS " ${FOO_SRCS})
MESSAGE(STATUS "FOO_HDRS " ${FOO_HDRS})

ADD_LIBRARY(foo ${FOO_SRCS})

